package com.fotoaf;

import java.io.File;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.Toast;

public class tomafoto extends Activity {
	/**
	 * @see android.app.Activity#onCreate(Bundle)
	 */
	private static int TAKE_PICTURE = 1;
	public String name = "";
	Intent intent;
	int code=TAKE_PICTURE ;
	
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.vwtomafoto);
		// TODO Coloque su código aquí
		try {
			Button btnAction=(Button) findViewById(R.id.btnTomaFoto);
			name = Environment.getExternalStorageDirectory() + "/fotoAF/"+principal.catalogo +".jpg";
			intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
			Uri output = Uri.fromFile(new File(name));
			//intent.putExtra("return-data",true);
			intent.putExtra(MediaStore.EXTRA_OUTPUT, output);		
			
			btnAction.setOnClickListener(new OnClickListener() {			
				@Override
				public void onClick(View v) {
					// TODO Auto-generated method stub
					startActivityForResult(intent, code);				
				}
			});
		} catch(Exception e) {
			Toast.makeText(tomafoto.this,e.toString() , Toast.LENGTH_SHORT).show();
		}
	}
	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		super.onActivityResult(requestCode, resultCode, data);
//		if (requestCode==TAKE_PICTURE) {			
//			//if(data!=null) {
//				ImageView iv = (ImageView)findViewById(R.id.imageView1);
//				//iv.setImageBitmap(BitmapFactory.decodeFile(name));
//				//iv.setima
//			//} else {
//				Toast.makeText(tomafoto.this,"sin datos", Toast.LENGTH_SHORT).show();				
//			//}
//		}
	}	
}
